/**
 *       Copyright (c) 2012 Lukas Zaruba
 *
 *   This file is part of Robot Playground.
 *
 *   Robot Playground is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   Robot Playground is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with Robot Playground. If not, see <http://www.gnu.org/licenses/>.
 */
package net.zarubsys.robotplayground.gui.session.utils;

import net.zarubsys.robotplayground.core.session.DeviceSessionContainer;
import net.zarubsys.robotplayground.core.session.ModuleSessionContainer;
import net.zarubsys.robotplayground.core.session.ProgramSessionContainer;
import net.zarubsys.robotplayground.core.session.Session;
import net.zarubsys.robotplayground.gui.session.providers.SystemObjectGUIProviderClass;

/**
 * SessionGUIUtils
 *
 * @author Lukas Zaruba, lukas.zaruba@gmail.com
 */
public class SessionGUIUtils {
	
	public static void executeOnAllSystemObjects(Session session, ISystemObjectAction action) {
		int i = 0;
		for (DeviceSessionContainer device : session.getDevices()) {
			action.run(session, device.getDeviceId(), i, SystemObjectGUIProviderClass.DEVICE);
			i++;
		}
		
		i = 0;
		for (ModuleSessionContainer module : session.getModules()) {
			action.run(session, module.getModuleId(), i, SystemObjectGUIProviderClass.MODULE);
			i++;
		}
		
		i = 0;
		for (String monitor : session.getMonitors()) {
			action.run(session, monitor, i, SystemObjectGUIProviderClass.MONITOR);
			i++;
		}
		
		i = 0;
		for (ProgramSessionContainer program : session.getPrograms()) {
			action.run(session, program.getProgramId(), i, SystemObjectGUIProviderClass.PROGRAM);
			i++;
		}
	}

}

